package com.ulic.customerManApplication.messagemodule.bo;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.ulic.customerManApplication.membermodule.bo.Member;
import com.ulic.customerManApplication.usermodule.bo.User;

@Entity
@Table(name="T_GYW_MESSAGERECORD")
@SequenceGenerator(name="messageRecord_seq",sequenceName="S_GYW_MESSAGEREC_ID")
public class MessageRecord implements Serializable{

	/**
	 * 手机发送信息记录
	 */
	private static final long serialVersionUID = 1L;
	private int message_id;//编号
	private User sender;//发送人
	private Set<Member> receiver = new HashSet<Member>();//接收人
	private String messageContent;//短信内容
	private String sendTime;//发送时间
	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE,generator="messageRecord_seq")
	public int getMessage_id() {
		return message_id;
	}
	public void setMessage_id(int messageId) {
		message_id = messageId;
	}
	 
	@ManyToMany(cascade = CascadeType.REFRESH)   
    @JoinTable(name = "t_gyw_member_messagerecord", inverseJoinColumns = @JoinColumn(name = "id"), joinColumns = @JoinColumn(name = "message_id")) 
	public Set<Member> getReceiver() {
		return receiver;
	}
	public void setReceiver(Set<Member> receiver) {
		this.receiver = receiver;
	}
	public String getMessageContent() {
		return messageContent;
	}
	public void setMessageContent(String messageContent) {
		this.messageContent = messageContent;
	}
	public String getSendTime() {
		return sendTime;
	}
	public void setSendTime(String sendTime) {
		this.sendTime = sendTime;
	}
	@ManyToOne(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY, optional = false)   
	@JoinColumn(name="UM_USER_ID")
	public User getSender() {
		return sender;
	}
	public void setSender(User sender) {
		this.sender = sender;
	}
	
}
